﻿using BCEntity.Common.Dictionary;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace BCData.Common.Dictionary
{
    /// <summary>
    /// 字典数据处理
    /// </summary>
    public interface IDictionaryReferenceData
    {
        /// <summary>
        /// 检查name在字典是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<bool> CheckName(string name);

        /// <summary>
        /// 检查备注是否存在字典中
        /// </summary>
        /// <param name="remark"></param>
        /// <returns></returns>
        Task<bool> CheckRemark(string remark);

        /// <summary>
        /// 检查备注和检索键是否同时存在
        /// </summary>
        /// <param name="remark"></param>
        /// <param name="searchKey"></param>
        /// <returns></returns>
        Task<bool> CheckRemarkAndSearchKey(string remark, string searchKey);

        /// <summary>
        /// 检查备注和名称是否同时存在
        /// </summary>
        /// <param name="remark"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<bool> CheckRemarkAndName(string remark, string name);

        /// <summary>
        /// 检查检索键是否存
        /// </summary>
        /// <param name="searchKey"></param>
        /// <returns></returns>
        Task<bool> CheckSearchKey(string searchKey);

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity">字典引用实体模型</param>
        Task<int> InsertAsync(DictionaryReferenceEntity entity);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">字典引用Id</param>
        Task<int> DeleteAsync(int id);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">字典引用实体模型</param>
        Task<int> UpdateAsync(DictionaryReferenceEntity entity);

        /// <summary>
        /// 通过id查询字典数据
        /// </summary>
        /// <param name="dictionaryReferenceId">字典Id</param>
        /// <returns></returns>
        Task<DictionaryReferenceEntity> GetByIdAsync(int dictionaryReferenceId);
        /// <summary>
        /// 获取字典数据
        /// </summary>
        /// <param name="searchKey">查询Key</param>
        /// <returns></returns>
        Task<DictionaryReferenceEntity> GetEntityAsync(string searchKey);
        /// <summary>
        /// 获取字典数据
        /// </summary>
        /// <param name="typeName">类型名称</param>
        /// <param name="name">名称</param>
        /// <returns></returns>
        Task<DictionaryReferenceEntity> GetEntityAsync(string typeName, string name);
        /// <summary>
        /// 通过一个类型下所有的字典
        /// </summary>
        /// <param name="typeName">类型名称</param>
        /// <returns></returns>
        Task<IEnumerable<DictionaryReferenceEntity>> GetByTypeNameAsync(string typeName);
        /// <summary>
        /// 通过一个父级获取以下所有的字典
        /// </summary>
        /// <param name="parentName"父名称></param>
        /// <returns></returns>
        Task<IEnumerable<DictionaryReferenceEntity>> GetByParentNameAsync(string parentName);
        /// <summary>
        /// 通过一个类型一个父级获取以下所有的字典
        /// </summary>
        /// <param name="typeName">类型名称</param>
        /// <param name="parentName"父名称></param>
        /// <returns></returns>
        Task<IEnumerable<DictionaryReferenceEntity>> GetByTypeNameAndParentNameAsync(string typeName, string parentName);
        /// <summary>
        /// 所有字典引用数据
        /// </summary>
        /// <param name="searchKey">查询Key</param>
        /// <param name="parentName">父级名称</param>
        /// <returns>字典数据列表</returns>
        Task<IEnumerable<DictionaryReferenceEntity>> GetAsync(string searchKey = null, string parentName = null);
        /// <summary>
        /// 获取字典数据列表
        /// </summary>
        /// <param name="searchKeys">键名列表字符串</param>
        /// <returns></returns>
        Task<IEnumerable<DictionaryReferenceEntity>> GetByInSearchKeyAsync(string searchKeys);
        /// <summary>
        /// 某一类型字典引用数据
        /// </summary>
        /// <param name="typeName">类型名称</param>
        /// <param name="parentName">父级名称</param>
        /// <returns>字典数据列表</returns>
        Task<IEnumerable<DictionaryReferenceEntity>> GetTypeRecordAsync(string typeName, string parentName = null);
        /// <summary>
        /// 查询引用值和引用类型相关数据
        /// </summary>
        /// <param name="itemValue">引用值（对应中文名称）</param>
        /// <param name="typeValue">引用类型值（对应中文类型名称）</param>
        /// <param name="pageIndex">起始页</param>
        /// <param name="pageSize">页数量</param>
        /// <param name="ascending">排序</param>
        /// <returns>字典数据列表</returns>
        Task<(int dataCount, IEnumerable<DictionaryReferenceEntity>)> GetAsync(int pageIndex, int pageSize, bool ascending, string itemValue = null, string typeValue = null);
    }
}
